package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.StrategySecondaryComment;
import cn.wolfcode.trip.base.mapper.StrategySecondaryCommentMapper;
import cn.wolfcode.trip.base.query.StrategySecondaryCommentQueryObject;
import cn.wolfcode.trip.base.service.IStrategySecondaryCommentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StrategySecondaryCommentServiceImpl implements IStrategySecondaryCommentService {
    @Autowired
    private StrategySecondaryCommentMapper strategySecondaryCommentMapper;

    /**
     * 新增攻略二级评论
     * @param strategySecondaryComment
     */
    public void save(StrategySecondaryComment strategySecondaryComment) {
        strategySecondaryCommentMapper.insert(strategySecondaryComment);
    }

    /**
     * 分页查询单个攻略一级评论下的所有二级评论
     * @param qo
     * @return
     */
    public PageInfo query(StrategySecondaryCommentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List list = strategySecondaryCommentMapper.selectForList(qo);
        return new PageInfo(list);
    }
}